﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class AdminControl_NewsDetails : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dataTable = new DataTable();
        dataTable.Columns.Add("writer");
        dataTable.Columns.Add("title");
        dataTable.Columns.Add("summary");
        dataTable.Columns.Add("postdate");
        dataTable.Columns.Add("edit");
        dataTable.Columns.Add("delete");

        ShoppingDataContext spdt = new ShoppingDataContext();
        var news = from p in spdt.NEWs
                   select p;

        foreach (var n in news)
        {
            DataRow row = dataTable.NewRow();
            row["writer"] = n.writer;
            row["title"] = n.title;
            row["sumary"] = n.summary;
            row["postdate"] = n.postdate;
            row["edit"] = "../AdminTool/EditNews.aspx?newsid=" + n.NewsID;
            row["delete"] = "DeleteProduct.aspx?proid=" + n.NewsID;
            dataTable.Rows.Add(row);
        }

        newsdetails.DataSource = dataTable;
        newsdetails.DataBind();
    }
}
